<template>

  <el-dialog title="发送设置" :visible.sync="$attrs.visableIf" @close="handleCloseDialog" :close-on-click-modal="false" :close-on-press-escape="false" append-to-body width="800px">
    <div class="content-big">
      <div class="content-right">
        <div class="table-head">
          <el-input v-model="queryParams.userName1" size="small" placeholder="搜索企微号" style="width: 200px;" clearable @keyup.enter.native="handleQuery" suffix-icon="el-icon-search"/>
          <el-button icon="el-icon-search" size="small"></el-button>
          <el-select v-model="queryParams.userName2" size="small" style="margin-left: 10px " filterable placeholder="请选择分组" @change="handleQuery">
            <el-option
              v-for="item in groupList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </div>
        <el-table
          :data="tableDataList"
          ref="companylabelList"

        >
          <el-table-column
            :label="item.label"
            align="center"
            v-for="(item, index) in tableColumns"
            :key="index"
            :prop="item.key"
            :min-width="item.minWidth ? item.minWidth : ``"
            :fixed="item.fixed ? item.fixed : false"
            :show-overflow-tooltip="true"
          >
            <!--用于表格自定义-->
            <template slot-scope="scope">
              <div v-if="item.key=='name'">
                <div class="userInfo">
                  <img src="../../../assets/images/profile.jpg"/>
                  <div class="user-big">
                    <div class="name">群聊</div>
                    <div class="label">成员<span>3</span></div>
                  </div>
                </div>

              </div>
              <div v-else style="text-align: center">{{ scope.row[item.key] }}</div>
            </template>
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作"
            width="100">
            <template slot-scope="scope">
              <el-button @click="handleSetting(scope.row)" type="text" size="small">设置</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>10"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>


    <div class="footer-btn" slot="footer">
      <el-button @click="handleCloseDialog">取消</el-button>
    </div>
    <setSendPage v-if="showSetSendPage" :visableIf.sync="showSetSendPage"></setSendPage>
  </el-dialog>
</template>

<script>


import {listUser} from "@/api/system/user";


export default {
  name: 'editSendSettings',
  components: {
    'setSendPage': () => import('./setSendPage.vue'),//导出弹窗
  },
  data() {
    return {
      // 查询参数
      showSetSendPage: false,
      input3: null,//群查找
      radio: null,//
      groupList: [
        {
          value: '0',
          label: '志新'
        }, {
          value: '1',
          label: '锐行'
        }
      ],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName1: null,
        userName2: null,
        userName3: null,
        userName4: null,
        userName5: null,
        userName6: null,
        userName7: null,
        userName8: null,
        userName9: null,
        userName10: null,
        userName11: null,
        userName12: null,
        userName13: null,
        userName14: null,
      },
      callList: [
        //称呼
        {id: 1, name: "有"},
        {id: 2, name: "无"},
      ],
      tableColumns: [
        {key: 'name', label: `企微号`, visible: true, minWidth: 150, fixed: true},
        {key: 'name2', label: `触发延迟`, visible: true, minWidth: 150, fixed: true},
        {key: 'status', label: `休眠时段`, visible: true, minWidth: 150, fixed: true},
      ],
      tableDataList: [],
      total: 8, // 表格的总条数
      multipleSelection: [],//表格多选
      showSelectSmartTags: false,//智能标签
      tableHeight: 600,
      dateRange1: [],
    }
  },
  created() {
    this.tableDataList = [];
    for (let i = 0; i < 10; i++) {
      let obj = {
        name: '小红',
        name2: '18207418337',
        status: '是',
      }
      this.tableDataList.push(obj);
    }
  },
  mounted() {

  },
  watch: {},
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    handleSetting(row) {
      this.showSetSendPage = true;
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(val) {
      this.multipleSelection = [];
      if (val && val.length > 0) {
        val.forEach((item) => {
          this.multipleSelection.push(item.id);
        })
      }
    },
    handleApplication(row) {
      //应用
    },
    handleStatusChange(row) {
      // console.log('状态', row.status);
      // let text = row.status == false ? "暂停" : "启用";
      // this.$modal.confirm(`确认要${text}广告计划（${row.name}）吗？`).then(function () {
      //   if (row.status == false) {
      //     return reqSubmittedStatusStopAlone(row.id);
      //   } else {
      //     return reqSubmittedStatusOpenAlone(row.id);
      //   }
      // }).then(() => {
      //   this.$modal.msgSuccess(text + "成功");
      //   this.getList();
      // }).catch(function () {
      //   row.status = row.status == 1 ? false : true;
      // });
    },
    handleCloseDialog() {
      this.$emit('update:visableIf', false);
      this.$emit('handleQuery');
    },
  }
}
</script>

<style scoped lang="scss">

.number {
  position: absolute;
  left: 10px;
  top: 0px;
  font-size: 14px;

  span {
    color: rgba(0, 0, 0, .65);
    color: rgb(240, 139, 0);
  }

  .el-button {
    color: #3370ff;
    border: none;
  }
}

.footer-btn {
  position: relative;


}

.userInfo {
  border-radius: 4px;
  margin: 8px 0;
  cursor: pointer;
  position: relative;
  padding-left: 50px;
  font-size: 14px;
  list-style: none;
  text-align: left;
  display: flex;
  align-items: center;
  justify-items: center;

  img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    left: 0px;
    top: 0px;
    position: absolute;
  }

  .label {
    margin-top: 2px;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #f90;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-big {
    display: flex;
    flex-direction: column;
    line-height: 18px;
  }
}

.content-big {
  display: flex;
  height: 100%;

  .content-left {
    width: 410px;
    background: #fff;
    border-right: 1px solid #eee;

    .title {
      background: #f5f5f5;
      color: #2f333c;
      font-weight: 700;
      padding: 12px 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

  }

  .content-right {
    flex: 1;

    .table-head {
      display: flex;
      align-items: center;
      height: 60px;
    }
  }
}

::v-deep .el-dialog__body {
  overflow-y: auto;
  height: 600px;
  padding: 20px;
}

.title-tips {
  position: absolute;
  top: -0px;
  left: 90px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;

  span {
    margin-left: 10px;
    color: #888;
  }
}

.el-checkbox-group {
  margin-top: 20px;

  .el-checkbox {
    margin-bottom: 12px;
    width: 150px;
  }
}

.title {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;

  span {
    color: #3370ff;
  }
}

.exclusion {
  margin: 12px 0px;
  padding: 12px 16px;
  border-radius: 2px;
  border: 1px solid #f0f0f0;
}
</style>
